
/*
*Pool Public Licence version 0.1 or later
*Released on 20th April 2008.
*Any voilations can be repoted at paritosh@wikiocean.net
*What is treated as voilations can be found at www.wikiocean.net/ppl1-voilations* 
******************************************************************************
* The contents of this file are subject Affero GPL v3 and later with additional conditions.
* The additional conditions are to be considered as part of the Affero GPL v3 and later.
* The additional conditions will supersede the Affero GPLv3 and later in case of conflict.
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.gnu.org/licenses/agpl.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Initial Developer of the Original Code is Paritosh Pungaliya.
* created by Paritosh Pungaliya are Copyright (C) Paritosh Pungaliya; All Rights Reserved.
* Contributions are Copyright (C) 2001-2008 Paritosh Pungaliya.

* Objective of the additional terms (license) 
* 1) Is to extend the software freedom to freedom to work.
* 2) To ensure that knowledge is free from monopoly of agencie(s).
* 3) To avoid a situation where big corporates or investors can buy out free software groups and companies and then start milking the communities built around it.
* (this trend can be seen how the openness changes in companies that get Venture Capital funding.)
* (if you agree to this logic I invite you to our group to work together)

* Additional conditions
*  0) Source code will also include
* 	a) data dictionaries, data ontologies which are used to alter the behavior of code or to control           the features of application.
* 	b) Any code generated or derived automatically or manually from this code or logic
*  1) The revenue generated by deploying, implementing , selling services and other activities
*  	 based on this source code should be shared 100%, between the people working on it.
*  2) Capital invested should be given only fixed rate of return or linked to revenue/surplus growth for limited time.
*  3) People working on the project should always have an option to replace the capital provider in full or part with lower cost capital.
*  4) Their should not be any ownership which can be sold as a claim on future profit to be generated from the work of people working on the code.
*  5) Brand thus generated should belong to the group.
*  6) For old and new members revenue sharing should be equal for same work equivalent.
*  7) The share of revenue should be decided by bidding for work before allocation of work within the group.
*  8) Before bidding various method of measuring the work should be clearly defined and published in public domain. Any change in process should also be publised in public domain imediately.
*  9) All data related to to revenue sharing should be published as and when generated in public domain.
*  10) For group of people having size more than 10 people will have to make it open online for others to participate in bids. 
*  11) All people involved in related and sub project will be treated as a group.
*  12) Once this license is being used for a certain code then all and any other software services being provided by the group should complusorilly come under 100% revenue sharing.
*  13) Cross subsidization should not happen under this revenue share, no additional benefit should be drawn from the people, by the employing agency.
*  14) Any position or knowledge or legal structure created relating to people working on code, which adversely affects the spirit of 100% revenue share will be treated as a violation.
*  15) Revenue sharing defined.
*     a) includes direct revenue and also intangible gains like brand, and organization.
*     b) No personal judgment should be involved in judging the distribution of revenue.It has to be pre-defined formula based.
*     c)100% of revenue should be shared before expenses and recievers should have control over what expenses to incur.
*     d)For the work done in any month by contributing group member, working on any project can be given revenue share from the work done by the group, for a maximum of 18 months after that month.
*     e)Revenue should be apportioned to the month in which work is done and not when received.
*  The group fulfilling the above conditions also has to be a wiki ecosystem further defined in www.wekosystem.org or read about Wekosystem at www.wikiocean.net

*  ******************************************************************************
*/  
package pool.tablename;


import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;

import timer.ExecutionTimer;
import timer.TimerRecordFile;
import utility.ConvertToLower;

import utility.MessageGenerator;
import utility.ReplacesSpecialCharacter;
import dbmanager.ChekInMaster;
import dbmanager.DBManager;
import dbmanager.GetIdName;

/**
 *@author Administrator
 *Trans_property_details class do the insertion for the properties of transaction
 *and Updation,Deletion and view operation  for the properties of transaction
 *which is present in Transaction. 
 *trans_property_details table has following columns
 *id stores id of  trans_property_details table
 *tid stores id of transaction table for which property has to be stored.
 *Pid  stores id of property of transaction from master table.
 *Pv stores id of value for pid from master table.
 *Vt stores the value of pv if value  entered in 'pv' is not present in master table.
 *Ref stores reference for particular transaction.
 */
public class Trans_property_details extends SubPool
{
	public Hashtable<Object,Object> PropertyMap = new Hashtable<Object, Object>();
	
	private String tpl_tableName = "trans_property_details";
	private String tid = "no$";		
	private String masterTable = "transaction";
	
	Vector<Object> TPropertyList =  new Vector<Object>();
	private Hashtable<Object, Object> TransactioMap;
	
	private Vector<Object> OldTransPropertyVector = new Vector<Object>();
	private Vector<Object> NewTransPropertyVector = new Vector<Object>();
	
	private Hashtable<Object,Object> ViewHashtable = new Hashtable<Object, Object>();
	
	public boolean boolTpdSetCommit = true;
	
	//boolean flagResult = false;	
	//private String td_tableName = "transaction_details";
	//private String PropertySPchar="";
	//private int count;
	
	public Trans_property_details()	{}
	
	public Trans_property_details(DBManager sqldb,String msg,String process,String Request)
	{
		ExecutionTimer t = new ExecutionTimer();
		t.start();
		this.Request = Request;
		this.process = process;
		this.sqlDB = sqldb;
		message = msg;		
		gin = new GetIdName(sqldb);
		t.end();
		@SuppressWarnings("unused")
		TimerRecordFile timerFile=new TimerRecordFile("pool.tablename","Trans_property_details","Trans_property_details",t.duration());
	}
	
	public Trans_property_details(DBManager sqldb)
	{	
		ExecutionTimer t = new ExecutionTimer();
		t.start();
		this.sqlDB = sqldb;
		gin = new GetIdName(sqldb);
		t.end();
		@SuppressWarnings("unused")
		TimerRecordFile timerFile=new TimerRecordFile("pool.tablename","Trans_property_details","Trans_property_details",t.duration());

	}
		/**
	 * getInsert method invoked by the object of DBManager i.e sqlDB 
	 * and pass a table name and hashtable as a parameter
	 */

	synchronized public StringBuffer getInsert() 
	{
		ExecutionTimer t = new ExecutionTimer();
		t.start();
		StringBuffer sbrDTB = new StringBuffer();
		
	
		
	
	//	Vector<Object>tplVector = new Vector<Object>();		
		//boolean flagReport = false;
		
		Vector<Object>tempVector = new Vector<Object>();
		
		tempVector.addAll(TPropertyList);
		//StringBuffer sbrDTB = new StringBuffer();
		ReplacesSpecialCharacter replace = new ReplacesSpecialCharacter(sqlDB);		
		ChekInMaster check = new ChekInMaster(sqlDB);
		
		try
		{
			System.out.println("pool::TransPropertyDetail::getInsert()::");
			
		    for(int i=0;i<tempVector.size();i++)
			{
				Hashtable<Object,Object> tempProperty1 = new Hashtable<Object,Object>();
				Trans_property_details ps = (Trans_property_details)tempVector.get(i);
				PropertyMap = gin.getRef(ps.PropertyMap);
				tempProperty1.putAll(ps.PropertyMap);
				tempProperty1.put("tid", tid);
				
				if(check.isInProperty_details(tempProperty1,tpl_tableName) == false)
				{	
					int j = sqlDB.getInsert(tpl_tableName, tempProperty1);
					if(j>0)
					{
						//tplVector.add(tempProperty1); // It will create the vector for the Reports class.
						System.out.println("\nretail::PropertyDetails ::getInsert():: Inserted Property in " + tpl_tableName + " .........\n\n" );
						sqlDB.pLog.Logger.append("\n "+ Request +" Added Success fully........ ");						
						sbrDTB.append(" Following property is Added... "+replace.ReplacesChar("Trans_property_details", tempProperty1,process));
						
						strID = tid;
						flagResult = true;
						//flagReport = true;						
					}
					else
					{	
						sbrDTB.append(" pool::PropertyDetails ::getInsert():: Unable to insert into Property Details ");
						System.out.println("pool::PropertyDetails ::getInsert():: Unable to insert into Property Details\n\n");
						sqlDB.pLog.Logger.append("\n Unable to insert into Trans_Property Details........ \n\n");												
						flagResult = false;
					}
					
					if(flagResult == true)
						continue;
					else
						break;
				}
				else
				{
					sbrDTB.append(" pool::PropertyDetails ::getInsert():: Property Already exist ");
					System.out.println("pool::PropertyDetails ::getInsert():: Property Already exist ");
					sqlDB.pLog.Logger.append("\n Property Already exist ");
					flagResult = false;
				}
			}
		    /*if(flagReport == true)
			{
				setVector(oldVector, tplVector);
				Request = tpl_tableName;
				getReport();
			}*/
		}	
		catch (Exception e) {
		}
		 boolTpdSetCommit = flagResult ;
		//sbrDTB.append(" Inserted in TPD ");
		t.end();
		@SuppressWarnings("unused")
		TimerRecordFile timerFile=new TimerRecordFile("pool.tablename","Trans_property_details","getInsert",t.duration());
		return sbrDTB;
	}
	
	/**
	 * @param tid as a id of transaction.
	 * getupdate contains oldTransactionMap and newTransactionMap.
	 * In oldTransactionMap it cointains id of the transaction that is tid,pid,pv,vt,ref
	 * of existing record and in newTransactionMap it contains pid,pv,ref of property 
	 * which is going to be modify. 
	 * If in new propertyMap only pid and pv is given and ref is not present then it
	 * modify the pid,pv and takes the ref of oldpropertyMap and put it in newPropertyMap.
	 * If single property present in the message according to the tid,pv,vt,ref it gets 
	 * the id of perticular transaction property and then modify it.  
	 * If multiple properties are presents in the a message  
	*/
	
	@SuppressWarnings("unchecked")
	public StringBuffer getUpdate() 
	{
		ExecutionTimer t = new ExecutionTimer();
		t.start();
		
		/*boolean flagReport = false;
        Vector<Object> pdbsNewVector = new Vector<Object>();
   		Vector<Object> pdbsOldVector = new Vector<Object>();*/
		

		for(int i = 0; i < NewTransPropertyVector.size();i++ )
		{
			
			Hashtable<Object,Object> newTransactionMap = new Hashtable<Object,Object>(); /** stores new message for Update.*/
			Hashtable<Object,Object> oldTransactionMap = new Hashtable<Object, Object>(); /** stores old message for Update.*/
			
			try
			{
				oldTransactionMap = (Hashtable<Object, Object>)OldTransPropertyVector.get(i);
				newTransactionMap = (Hashtable<Object, Object>)NewTransPropertyVector.get(i);
			}
			catch (Exception e)
			{
				newTransactionMap = (Hashtable<Object, Object>)NewTransPropertyVector.get(i);
				oldTransactionMap.put("tid", newTransactionMap.get("tid"));
				oldTransactionMap.put("pid", newTransactionMap.get("pid"));
			}
			try 
			{
			  	Hashtable<Object, Object> temp = new Hashtable<Object, Object>();
			  	Hashtable<Object, Object> temp1 = new Hashtable<Object, Object>();
	      		try 
				{
	      			temp = sqlDB.getSelectCheck(oldTransactionMap,tpl_tableName);
					if (temp.containsKey("Error")) 
					{
						flagResult = false;
						return new StringBuffer(oldTransactionMap.toString());
					}
					temp = ConvertToLower.convertHashKey(temp);
				} catch (Exception e) {
				}
			  	temp1.putAll(temp);
			  	temp1.putAll(oldTransactionMap);
				oldTransactionMap = temp1; 
					
	        	temp.putAll(newTransactionMap);
	        	newTransactionMap.clear();
	        	newTransactionMap.putAll(temp);
	        }
			catch (Exception e){}
		
			ChekInMaster check = new ChekInMaster(sqlDB);
			
           	if (check.isInProperty_details(oldTransactionMap,tpl_tableName) == false)
			{
				sbrDTB.append("Old Property Not Present ");
				System.out.println("Old Property Not Present ");
				sqlDB.pLog.Logger.append("\n Old Property Not Present ");
				flagResult = false;
				return sbrDTB;
			}
			if (check.isInProperty_details(newTransactionMap,tpl_tableName) == true)
			{
				sbrDTB.append(" pool::PropertyDetails ::getUpdate():: New Property is Present");
				System.out.println("pool::PropertyDetails ::getUpdate():: New Property is Present ");
				sqlDB.pLog.Logger.append("\n New Property is Present");
				flagResult = false;
				return sbrDTB;
			}
			
			if(check.isInProperty_details(newTransactionMap,tpl_tableName) == false && check.isInProperty_details(oldTransactionMap,tpl_tableName) == true )
			{	
				
				if((oldTransactionMap.get("tid").equals(newTransactionMap.get("tid"))))
				{
					if((oldTransactionMap.get("pid").equals(newTransactionMap.get("pid"))))
					{
						int j=sqlDB.getUpdate(tpl_tableName, newTransactionMap, oldTransactionMap);
						if(j>0)
			       		{
													
			       			sqlDB.pLog.Logger.append("\n "+ Request +" updated Success fully........ ");						
							sbrDTB.append("Following property is updated... "+newTransactionMap.toString());
							
							strID = oldTransactionMap.get("tid").toString();
							flagResult = true;							
			       		}
						else
						{
							System.out.println("pool::Trans_property_details::getUpdate():: Unable to Update........");
							sbrDTB.append(" Unable to Update ");
							flagResult = false;
						}
						
						if(flagResult == true)
							continue;
						else
							break;
						/*newTransactionMap.put("id",newTransactionMap.get("tid"));
						oldTransactionMap.put("id",newTransactionMap.get("tid"));
						pdbsOldVector.add(oldTransactionMap); // It will create the vector for the Old property.
		    			pdbsNewVector.add(newTransactionMap); // It will create the vector for the New property.
		    			flagReport = true;*/
				
					}
					else
					{
						sbrDTB.append(" pool::PropertyDetails ::getUpdate():: new and old Pid  are not  same ");
						flagResult = false;
					}								
				}
				else
				{
					sbrDTB.append(" pool::PropertyDetails ::getUpdate()::new and old tid  are not  same  ");
					flagResult = false;
				}
				
           	}	
			else
			{
				System.out.println("pool::MasterClass::getUpdate():: Unable to Update. old property is not present ");
				sbrDTB.append("Unable to Update. old property is not present .");		
				flagResult = false;
			}
		}
		/*if(flagReport == true)
		{
			setVector(pdbsNewVector, pdbsOldVector);
			Request = tpl_tableName;
			getReport();
			PropertyDetailsBasicReports pdbs = new PropertyDetailsBasicReports(pdbsOldVector,sqlDB,process);
			pdbs.updateReport(pdbsNewVector);
		}*/
		t.end();
		@SuppressWarnings("unused")
		TimerRecordFile timerFile=new TimerRecordFile("pool.tablename","Trans_property_details","directUpdate",t.duration());
		return sbrDTB;
	}
	

	
	@SuppressWarnings("unchecked")
	@Override
	
	public StringBuffer getView()
	{
		ExecutionTimer t = new ExecutionTimer();
		t.start();
		
		StringBuffer sbrProperty=new StringBuffer();
		MessageGenerator msg=new MessageGenerator(sqlDB);		
		
		Hashtable<Object, Object> propertyHash= new Hashtable<Object, Object>();
		propertyHash.putAll(ViewHashtable);
		String mastermsg="";		
		
		Enumeration< Object> enum1 = propertyHash.keys();
		if(enum1.hasMoreElements()==false)
		{
				//sbrProperty.append("Enter condition to view the properties");
				//return sbrProperty;
		}
		if(propertyHash.size()==0)
		{
			if(TransactioMap.containsKey("tid"))
				propertyHash.put("tid", TransactioMap.get("tid"));
		}
		//According to the propertyHash getSelectVector method checks the condition ,searches all the record
		//through databse and stores into the vrs vector.
		if(propertyHash.size()==1)
		{
			if(propertyHash.containsKey("pid"))
			{
				sbrProperty.append("plz Enter the value of property ");
				return sbrProperty;
			
			}
		}
		Vector<Object> vrs  = new Vector<Object>(); 
			vrs.addAll(sqlDB.getSelectVector(propertyHash, tpl_tableName));
		String lastMid="";
		String presentproperties="";
		
		//For the wrong input to the trans_property_details request it shows empty records.		
		
		if(vrs.isEmpty())
		{
			sbrProperty.append("Record not available");
			return sbrProperty;
		}
			
		StringBuffer Heading =new StringBuffer();			
		
		for(int i=0;i<vrs.size();i++)
		{
				String presentproperty="";
				String Master="";
				Hashtable<Object, Object> hashobj=new Hashtable<Object, Object>();
				hashobj=(Hashtable<Object, Object>) vrs.get(i);
				
				//hashobj contain whole record which has taken through the database according to the condition value. 
				
				hashobj.putAll(ConvertToLower.convertHashKey(hashobj));
					
				//TransactioMap is set from the transation table which contain an id of transaction only if the request is for  transaction 
				//and there is a direct request to the trans_property_details then it shows empty TransactioMap. 
				
				//removed  the fields through the hash which is already presents in the TransactioMap  through the removeDuplFromhash method.
				
				Hashtable<Object, Object> hash=new Hashtable<Object, Object>();
				hash.put("tid",hashobj.get("tid") );
				hash=gin.removeDuplFromhash(TransactioMap,hash);
				
				//Master contain an tid in case of direct request to the trans_property_details and shows empty in case of request is 
				//through the transaction.
			
				if(hash.isEmpty()==false)
				{
					hash.put("id",hashobj.get("tid") );
					hash.remove("tid");
				}
				
			/*	Master=msg.convertToMessage(masterTable,process, hash);
				mastermsg=Master;*/
				
				try {
					hashobj.putAll(gin.CheckFromMaster(hashobj,process));
					Heading.append(hashobj.get("pid")+"\t");
					String value = hashobj.get("pv").toString();
					if(value.equals("0") || value.length()==0)
						value = hashobj.get("vt").toString();
					sbrProperty.append(value+"\t");
				} catch (Exception e) {
					e.printStackTrace();
				}
		
			//	presentproperty=msg.convertToMessage(tpl_tableName, process, hashobj);
				
				//Here each property gets checked according to the  mid if the present mid matches  with the previous mid then
				//present property gets concat with the previous property.
				//If mid is not matching then the property gets added with itd mid or mastermsg.
				
				/*if(lastMid.equals(mastermsg))
				{
					presentproperties=presentproperties+presentproperty;						
				}
				else
				{
					presentproperties=presentproperties+mastermsg+presentproperty;
				}
				
				lastMid=Master;*/				
		}
		Heading.append("\n"+sbrProperty);
		sbrProperty = Heading;
		
		
		t.end();
		@SuppressWarnings("unused")
		TimerRecordFile timerFile=new TimerRecordFile("pool.tablename","Trans_property_details","getView",t.duration());
		return sbrProperty;
	
	}
	
	public void setTid(String tid)
	{
		ExecutionTimer t = new ExecutionTimer();
		t.start();
		this.tid = tid;
		t.end();
		@SuppressWarnings("unused")
		TimerRecordFile timerFile=new TimerRecordFile("pool.tablename","Trans_property_details","settid",t.duration());
	}
	
	public void setProcess(String tempProcess) 
	{
		ExecutionTimer t = new ExecutionTimer();
		 t.start();
		process = tempProcess;
		t.end();
		@SuppressWarnings("unused")
		TimerRecordFile timerFile=new TimerRecordFile("pool.tablename","Master_table","setProcess",t.duration());
	}
	
	
	public Hashtable<Object, Object> getBasicHashtable() {
		// TODO Auto-generated method stub
		return null;
	}
	
	public String getType() {
		// TODO Auto-generated method stub
		return null;
	}
	
	public void setPropertyVector(Vector<Object> propertydetails) 
	{
		this.TPropertyList=propertydetails;
		
	}
	public void setHashtable(Hashtable<Object, Object> table) {
		// TODO Auto-generated method stub
		
	}
	
	public void setTransactionMap(Hashtable<Object, Object> hashobj) 
	{
		ExecutionTimer t = new ExecutionTimer();
		t.start();
	this.TransactioMap=hashobj;
	t.end();
	@SuppressWarnings("unused")
	TimerRecordFile timerFile=new TimerRecordFile("pool.tablename","Trans_property_details","setTransactionMap",t.duration());
		
	}
	
	@Override
	public StringBuffer getDelete() {
		// TODO Auto-generated method stub
		return null;
	}
	
	public void setNewPropertyVector(Vector<Object> NewPropertyVector)
	{
		ExecutionTimer t = new ExecutionTimer();
		 t.start();
		this.NewTransPropertyVector = NewPropertyVector;	
		t.end();
		@SuppressWarnings("unused")
		TimerRecordFile timerFile=new TimerRecordFile("pool.tablename","Property_details","setNewPropertyVector",t.duration());
	}
	
	public void setOldPropertyVector(Vector<Object> OldPropertyVector)
	{
		ExecutionTimer t = new ExecutionTimer();
		 t.start();
		this.OldTransPropertyVector = OldPropertyVector;	
		t.end();
		@SuppressWarnings("unused")
		TimerRecordFile timerFile=new TimerRecordFile("pool.tablename","Property_details","setOldPropertyVector",t.duration());
	}
	
	public void setViewHashtable(Hashtable<Object,Object> hashtable) {
		ViewHashtable.putAll(hashtable);
	}
	
	//@Override
	/*synchronized public StringBuffer getUpdate() 
	{
		ExecutionTimer t = new ExecutionTimer();
		t.start();
		ResultSet rs = null;
		String pipeChar = null;
		Command cp = new Command(Request,sqlDB);
		//SpecialCharacter sp=new SpecialCharacter();
		String msg=" ";
		Hashtable<Object,Object> TempHash = new Hashtable<Object,Object>();
		boolean flagReport = false;
        Vector<Object> pdbsNewVector = new Vector<Object>();
   		Vector<Object> pdbsOldVector = new Vector<Object>();
   		try
		{	
			rs = sqlDB.getSelect("select fieldname,spchar,order1 from command where msgtype='" + tpl_tableName + "' and from_master='yes' and process='add' order by order1");					
			rs.next();
			pipeChar = rs.getString("spchar");
			rs.close();
		}
		catch(Exception e)
		{
			System.out.println("Pipe Char is not Found in Database");
		}
		
		
		TempHash = null;
		
		
		int index=0;
		count = cp.getCountof(message, tpl_tableName, process);//	getCount();
		if(count!=0)
		{
			try 
			{
				rs = sqlDB.getSelect("select fieldname,spchar,order1 from command where msgtype='"+ tpl_tableName+ "' and from_master='yes' and process='mod' and order1>0 order by order1");
				rs.next();
				PropertySPchar = rs.getString("spchar");
				rs.close();
			} 
			catch (SQLException e) {
			}
			index = Index.indexOf(message,PropertySPchar,index+1);
		}
		
		try 
		{
			tid=message.substring(0,index);
			TempHash = cp.getHashCommand(td_tableName,tid, "add");
			if(TempHash.containsKey("ErrorInput"))
		 	{
				return new StringBuffer(TempHash.toString());
			}
			tid = TempHash.get("tid").toString();
		} 
		catch (Exception e1) 
		{
			return new StringBuffer("Please Check the Transaction ID ");
		}
		while(count!=0)
		{
			Hashtable<Object,Object> newTransactionMap = new Hashtable<Object,Object>(); *//** It will get stores new mesage for Update.*//*
			Hashtable<Object,Object> oldTransactionMap = new Hashtable<Object, Object>(); *//** It will get stores old mesage for Update.*//*
		
			newTransactionMap.put("tid", tid);
			oldTransactionMap.put("tid", tid);
			if(index==-1)
			{
				break;
			}
			count--;
			try
			{
				int start=0;
				int end=0;
				start = index;
				msg = message.substring(start+1);
				if(msg.contains(PropertySPchar))
				{
					end = Index.indexOf(msg,PropertySPchar)+start;
					msg = message.substring(start,end+1);
				}
				else
				{
					msg= message.substring(start);
					
				
				}
				index= end+1;
			}
			catch (Exception e)
			{
				e.printStackTrace();
			}
			String msg1="";
			String msg2="";
			int start=0;
			boolean TYPEFLAG = false;
		
			if(msg.contains(pipeChar))
			{
				int end1=0;
				end1 = Index.indexOf(msg,pipeChar,end1+1);
				if(end1==-1)
				{
					newTransactionMap.put("ErrorInput","Item should insert");
				}
				msg1 = msg.substring(start, end1);
				
				TYPEFLAG = true;
			}
			else
			{
				msg1=msg;
			}
		
	        newTransactionMap.putAll(cp.getHashCommand(tpl_tableName, msg1, process));
	    	if(newTransactionMap.containsKey("ErrorInput"))
		 	{
				return new StringBuffer(newTransactionMap.toString());
			}
	        newTransactionMap = ConvertToLower.convertHashKey(newTransactionMap);
            newTransactionMap =gin.ConvertPVtoVT(newTransactionMap);
            newTransactionMap = gin.convertMasterId(newTransactionMap, tpl_tableName, "add");
            PropertyMap = cp.checkError(newTransactionMap, tpl_tableName); 
			if (PropertyMap.containsKey("ErrorInput")) 
			{
				return new StringBuffer(PropertyMap.toString());
			}
			if(TYPEFLAG)
			{
				start = Index.indexOf(msg, pipeChar, start + 1);
		        msg2 = msg.substring(start, msg.length());
		        oldTransactionMap.putAll(cp.getHashCommand(tpl_tableName, msg2, "add"));
		    	if(oldTransactionMap.containsKey("ErrorInput"))
			 	{
					return new StringBuffer(oldTransactionMap.toString());
				}
		        oldTransactionMap = ConvertToLower.convertHashKey(oldTransactionMap);
		        oldTransactionMap =gin.ConvertPVtoVT(oldTransactionMap);
		        oldTransactionMap = gin.convertMasterId(oldTransactionMap, tpl_tableName,process);
		         PropertyMap.putAll(cp.checkError(oldTransactionMap , tpl_tableName));
		        if(PropertyMap.containsKey("ErrorInput"))
				{
					return new StringBuffer(PropertyMap.toString());
				}
			}   
			else
		    {
				oldTransactionMap.put("pid", newTransactionMap.get("pid"));
		    }
			
			try 
			{
			  	Hashtable<Object, Object> temp = new Hashtable<Object, Object>();
			  	Hashtable<Object, Object> temp1 = new Hashtable<Object, Object>();
          		try 
				{
          			temp = sqlDB.getSelectCheck(oldTransactionMap,tpl_tableName);
					if (temp.containsKey("Error")) 
					{
						return new StringBuffer(temp.toString());
					}
					temp = ConvertToLower.convertHashKey(temp);
				} catch (Exception e) {
				}
			  	temp1.putAll(temp);
			  	temp1.putAll(oldTransactionMap);
				oldTransactionMap = temp1; 
					
            	temp.putAll(newTransactionMap);
            	newTransactionMap.clear();
            	newTransactionMap.putAll(temp);
            }
			catch (Exception e)
			{
			}
		
		    ChekInMaster check = new ChekInMaster(sqlDB);
           	if (check.isInProperty_details(oldTransactionMap,tpl_tableName) == false)
			{
				sbrDTB.append("Old Property Not Present ");
				System.out.println("Old Property Not Present ");
				sqlDB.pLog.Logger.append("\n Old Property Not Present ");
				return sbrDTB;
			}
			if (check.isInProperty_details(newTransactionMap,tpl_tableName) == true)
			{
				sbrDTB.append(" pool::PropertyDetails ::getUpdate():: New and Old Property are same ");
				System.out.println("pool::PropertyDetails ::getUpdate():: New and Old Property are same ");
				sqlDB.pLog.Logger.append("\n New and Old Property are same ");
				return sbrDTB;
			}
			
			if(check.isInProperty_details(newTransactionMap,tpl_tableName) == false && check.isInProperty_details(oldTransactionMap,tpl_tableName) == true )
			{	
				int j=sqlDB.getUpdate(Request, newTransactionMap, oldTransactionMap);
				if(j>0)
	       		{
	       			sqlDB.pLog.Logger.append("\n "+ Request +" updated Success fully........ ");						
					sbrDTB.append(" updated Success fully........ ");
					
	       		}
				newTransactionMap.remove("id");
				oldTransactionMap.remove("id");
				pdbsOldVector.add(oldTransactionMap); // It will create the vector for the Old property.
    			pdbsNewVector.add(newTransactionMap); // It will create the vector for the New property.
    			flagReport = true;
           	}	
		}
		if(flagReport == true)
		{
			setVector(pdbsNewVector, pdbsOldVector);
			Request = tpl_tableName;
			getReport();
			PropertyDetailsBasicReports pdbs = new PropertyDetailsBasicReports(pdbsOldVector,sqlDB,process);
			pdbs.updateReport(pdbsNewVector);
		}
		t.end();
		@SuppressWarnings("unused")
		TimerRecordFile timerFile=new TimerRecordFile("pool.tablename","Trans_property_details","getUpdate",t.duration());
		return sbrDTB;
	}*/

	/*public StringBuffer getView()
	{
		ExecutionTimer t = new ExecutionTimer();
		t.start();
		
		StringBuffer sbrProperty=new StringBuffer();
		MessageGenerator msg=new MessageGenerator(sqlDB);
		Hashtable<Object, Object> MasterHash= new Hashtable<Object, Object>();
		Command cp=new Command(message,sqlDB);
		Hashtable<Object, Object> PropertyMap = new Hashtable<Object, Object>();
		PropertyMap.putAll(cp.getHashCommand(tpl_tableName, message, process));
		if(PropertyMap.containsKey("ErrorInput"))
		{
			sbrProperty.append(PropertyMap.get("ErrorInput"));
			return sbrProperty;
		}
		
		if(PropertyMap.containsKey("ErrorInput"))
		{
			
			sbrProperty.append("Error in input str");
			return sbrProperty;
		}
		
		//MasterHash stores the  transaction id from the transaction table.
		
		MasterHash.putAll(ConvertToLower.convertHashKey(cp.getHashCommand(masterTable, message, process)));
		Hashtable<Object, Object> propertyHash= new Hashtable<Object, Object>();
		String mastermsg="";
			
		//propertyHash stores all the input information given in the  request e.g tid(transaction id),Pid,Pv,Vt 
		//for the direct request to the trans_property_details or stores tid if the request is through the transaction. 
		
		propertyHash.putAll(cp.getHashCommand(tpl_tableName, message, process));
		if(propertyHash.containsKey("ErrorInput"))
		{
			sbrProperty.append(propertyHash.get("ErrorInput"));
			return sbrProperty;
		}
			
		propertyHash.putAll(gin.ConvertPVtoVT(propertyHash));
		propertyHash.putAll(gin.convertMasterId(propertyHash, tpl_tableName, process));
		propertyHash.putAll(ConvertToLower.convertHashKey(propertyHash));
		if(propertyHash.get("pv").toString()=="0")
		{
			propertyHash.remove("pv");
		}
		propertyHash = gin.getHashMapOfValues(propertyHash);
		
		Enumeration< Object> enum1 = propertyHash.keys();
		if(enum1.hasMoreElements()==false)
		{
				sbrProperty.append("Enter condition to view the properties");
				return sbrProperty;
		}
		
		//According to the propertyHash getSelectVector method checks the condition ,searches all the record
		//through databse and stores into the vrs vector.
		if(propertyHash.size()==1)
		{
			if(propertyHash.containsKey("pid"))
			{
				sbrProperty.append("plz Enter the value of property ");
				return sbrProperty;
			
			}
		}
		Vector<Object> vrs  = new Vector<Object>(); 
			vrs.addAll(sqlDB.getSelectVector(propertyHash, tpl_tableName));
		String lastMid="";
		String presentproperties="";
		
		//For the wrong input to the trans_property_details request it shows empty records.
		
		
		if(vrs.isEmpty())
		{
			sbrProperty.append("Record not available");
			return sbrProperty;
		}
			
		
		for(int i=0;i<vrs.size();i++)
		{
				String presentproperty="";
				String Master="";
				Hashtable<Object, Object> hashobj=new Hashtable<Object, Object>();
				hashobj=(Hashtable<Object, Object>) vrs.get(i);
				
				//hashobj contain whole record which has taken through the database according to the condition value. 
				
				hashobj.putAll(ConvertToLower.convertHashKey(hashobj));
					
				//TransactioMap is set from the transation table which contain an id of transaction only if the request is for  transaction 
				//and there is a direct request to the trans_property_details then it shows empty TransactioMap. 
				
				//removed  the fields through the hash which is already presents in the TransactioMap  through the removeDuplFromhash method.
				
				Hashtable<Object, Object> hash=new Hashtable<Object, Object>();
				hash.put("tid",hashobj.get("tid") );
				hash=gin.removeDuplFromhash(TransactioMap,hash);
				
				//Master contain an tid in case of direct request to the trans_property_details and shows empty in case of request is 
				//through the transaction.
			
				if(hash.isEmpty()==false)
				{
					hash.put("id",hashobj.get("tid") );
					hash.remove("tid");
				}
				
				Master=msg.convertToMessage(masterTable,process, hash);
				mastermsg=Master;
				if(mastermsg.equals(""))
				{
					sbrProperty.append("Check Transaction spchar or Transaction-id ");
					return sbrProperty;
				}
				hashobj.putAll(gin.CheckFromMaster(hashobj,process));
				presentproperty=msg.convertToMessage(tpl_tableName, process, hashobj);
				
				//Here each property gets checked according to the  mid if the present mid matches  with the previous mid then
				//present property gets concat with the previous property.
				//If mid is not matching then the property gets added with itd mid or mastermsg.
				
				if(lastMid.equals(mastermsg))
				{
						presentproperties=presentproperties+presentproperty;						
				}
				else
				{
					presentproperties=presentproperties+mastermsg+presentproperty;
				}
				
				lastMid=Master;				
		}
		
		sbrProperty.append(presentproperties);
		t.end();
		TimerRecordFile timerFile=new TimerRecordFile("pool.tablename","Trans_property_details","getView",t.duration());
		return sbrProperty;
	
	}
	
	public void setRequest(String Request) 
	{
		ExecutionTimer t = new ExecutionTimer();
		t.start();
	this.Request = Request; 
	t.end();
	@SuppressWarnings("unused")
	TimerRecordFile timerFile=new TimerRecordFile("pool.tablename","Trans_property_details","setRequest",t.duration());
		
	}
	
	public String getProceess() {
		// TODO Auto-generated method stub
		return null;
	}
	
	public String getTable() 
	{
		return Request;
	}
	
	
	*/
	/**
	 * Set the object of DBManager GetIdName of the object of DBManager 
	 * and store it in gin object of  GetIdName.
	 */
	/*public void setDbmanager(DBManager database) 
	{
		
		ExecutionTimer t = new ExecutionTimer();
		t.start();
		this.sqlDB = database;
		gin= new GetIdName(sqlDB);
		t.end();
		@SuppressWarnings("unused")
		TimerRecordFile timerFile=new TimerRecordFile("pool.tablename","Trans_property_details","setDbmanager",t.duration());
	}*/	
	

	public Hashtable<Object, Object> getDetailHashtabel() {
		// TODO Auto-generated method stub
		return null;
	}
	public Hashtable<Object, Object> getHashtabel() {
		// TODO Auto-generated method stub
		return null;
	}
	public Vector<Object> getpropertyVector() 
	{	
		return TPropertyList;
	}
	public String getTable() 
	{
		return Request;
	}
}

